package com.note.chh.notebook.Adapter;

import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.note.chh.notebook.Model.NewMusicModel;
import com.note.chh.notebook.R;

/**
 * Created by caihuahui on 2018/4/2.
 */

public class DialogNewAdapter extends BaseQuickAdapter<NewMusicModel.DataBean,BaseViewHolder> {
    public DialogNewAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, NewMusicModel.DataBean item) {
        ImageView mImage_aca = (ImageView) helper.getView(R.id.mImage_aca);
//        mImage_aca.setBackgroundResource(R.drawable.animation_play_music_img);
//        AnimationDrawable animation = (AnimationDrawable) mImage_aca.getBackground();
        if (!item.getFilename().isEmpty()) {
            String[] split = item.getFilename().split("-");
            helper.setText(R.id.mText_singer," - "+split[0]);
            if (split.length>=2) {
                helper.setText(R.id.mText_musicName,split[1]);
            }else{
                helper.setText(R.id.mText_musicName,"");
            }
        }
        if (item.getSqhash().equals("true")) {
            mImage_aca.setVisibility(View.VISIBLE);
//            if (!animation.isRunning()) {
//                animation.start();
//            }
        }else{
            mImage_aca.setVisibility(View.GONE);
//            if (animation.isRunning()) {
//                animation.stop();
//            }
        }
    }
}
